package com.tyut.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tyut.common.annotation.Log;
import com.tyut.common.core.controller.BaseController;
import com.tyut.common.core.domain.AjaxResult;
import com.tyut.common.enums.BusinessType;
import com.tyut.system.domain.TyutSoftness;
import com.tyut.system.service.ITyutSoftnessService;
import com.tyut.common.utils.poi.ExcelUtil;
import com.tyut.common.core.page.TableDataInfo;

/**
 * 软著Controller
 * 
 * @author tyut
 * @date 2023-11-21
 */
@RestController
@RequestMapping("/alldoc/softness")
public class TyutSoftnessController extends BaseController
{
    @Autowired
    private ITyutSoftnessService tyutSoftnessService;

    /**
     * 查询软著列表
     */
    @PreAuthorize("@ss.hasPermi('alldoc:softness:list')")
    @GetMapping("/list")
    public TableDataInfo list(TyutSoftness tyutSoftness)
    {
        startPage();
        List<TyutSoftness> list = tyutSoftnessService.selectTyutSoftnessList(tyutSoftness);
        return getDataTable(list);
    }

    /**
     * 导出软著列表
     */
    @PreAuthorize("@ss.hasPermi('alldoc:softness:export')")
    @Log(title = "软著", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TyutSoftness tyutSoftness)
    {
        List<TyutSoftness> list = tyutSoftnessService.selectTyutSoftnessList(tyutSoftness);
        ExcelUtil<TyutSoftness> util = new ExcelUtil<TyutSoftness>(TyutSoftness.class);
        util.exportExcel(response, list, "软著数据");
    }

    /**
     * 获取软著详细信息
     */
    @PreAuthorize("@ss.hasPermi('alldoc:softness:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tyutSoftnessService.selectTyutSoftnessById(id));
    }

    /**
     * 新增软著
     */
    @PreAuthorize("@ss.hasPermi('alldoc:softness:add')")
    @Log(title = "软著", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TyutSoftness tyutSoftness)
    {
        return toAjax(tyutSoftnessService.insertTyutSoftness(tyutSoftness));
    }

    /**
     * 修改软著
     */
    @PreAuthorize("@ss.hasPermi('alldoc:softness:edit')")
    @Log(title = "软著", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TyutSoftness tyutSoftness)
    {
        return toAjax(tyutSoftnessService.updateTyutSoftness(tyutSoftness));
    }

    /**
     * 删除软著
     */
    @PreAuthorize("@ss.hasPermi('alldoc:softness:remove')")
    @Log(title = "软著", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tyutSoftnessService.deleteTyutSoftnessByIds(ids));
    }
}
